package com.prince.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DateUtil {

    /**
	 * 根据传入的日期，获取相隔分钟的日期
	 * 
	 * @param date
	 * @param anyMinute
	 *            可正可负
	 * @return
	 */
	public static Date getAnyMinuteByNo(Date date, int anyMinute) {
		if (date == null) {
			return null;
		}
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.MINUTE, anyMinute);
		return c.getTime();
	}
	
    /**
     * 获取当前时间
     * @return
     */
    public static String currentDateTime(String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(new Date());
    }
    
    /**
     * 获取当前时间
     * @return
     */
    public static String currentTimes() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
        return sdf.format(new Date());
    }
    /**
     * 获取当前时间
     * @return
     */
    public static String currentDateFormat() {
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    	return sdf.format(new Date());
    }
    
    /**
     * 获取当前时间
     * @return
     */
    public static String currentTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        return sdf.format(new Date());
    }
    
    /**
     * 获取当前时间
     * @return
     */
    public static String currentDateTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(new Date());
    }

    /**
     * 获取当前日期
     * @return
     */
    public static String currentDate() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(new Date());
    }
    /**
     * 获取当前日期
     * @return
     */
    public static String currentYearAndMonth() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        return sdf.format(new Date());
    }

    /**
     * 获取当前年份
     * @return
     */
    public static String currentYear() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        return sdf.format(new Date());
    }

    /**
     * 获取当前月份
     * @return
     */
    public static String currentMonth() {
        SimpleDateFormat sdf = new SimpleDateFormat("MM");
        return sdf.format(new Date());
    }

    public static String currentDay() {
        SimpleDateFormat sdf = new SimpleDateFormat("dd");
        return sdf.format(new Date());
    }

    /**
     * 获得指定日期的前一天
     * 
     * @param specifiedDay
     * @return
     * @throws Exception
     */
    public static String getSpecifiedDayBefore(String specifiedDay) {

        Calendar c = Calendar.getInstance();
        Date date = null;
        try {
            date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                    .parse(specifiedDay);
        } catch (ParseException e) {
            try {
                date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
            } catch (ParseException e1) {
                e1.printStackTrace();
            }
        }
        c.setTime(date);
        int day = c.get(Calendar.DATE);
        c.set(Calendar.DATE, day - 1);

        String dayBefore = new SimpleDateFormat("yyyy-MM-dd").format(c
                .getTime());
        return dayBefore;
    }
    
    /**
    * @Title: compareTime 
    * @Description: 对比分钟大小 
    * @param time1
    * @param time2
    * @return boolean    返回类型 
    * @throws ParseException    设定文件 
     */
    public static boolean compareTime(String time1,String time2) throws ParseException{

        SimpleDateFormat farmat = new SimpleDateFormat("HH:mm");

        return compareDateTime(farmat.parse(time1),farmat.parse(time2))>=0;
    }
    
    /**
     * 获得指定日期的后一天
     * 
     * @param specifiedDay
     * @return
     */
    public static String getSpecifiedDayAfter(String specifiedDay) {
        Calendar c = Calendar.getInstance();
        Date date = null;
        try {
            date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                    .parse(specifiedDay);
        } catch (ParseException e) {
            try {
                date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
            } catch (ParseException e1) {
                e1.printStackTrace();
            }
        }
        c.setTime(date);
        int day = c.get(Calendar.DATE);
        c.set(Calendar.DATE, day + 1);

        String dayAfter = new SimpleDateFormat("yyyy-MM-dd")
                .format(c.getTime());
        return dayAfter;
    }

    /**
     * 获得指定日期的n天前或后
     * 
     * num为正时：num天后 num为负时：num天前
     * 
     * @param specifiedDay
     * @return
     */
    public static String getSpecifiedDay(String specifiedDay,
            String dateFormat, int num) {
        Calendar c = Calendar.getInstance();
        Date date = null;
        try {
            date = new SimpleDateFormat(dateFormat).parse(specifiedDay);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        c.setTime(date);
        int day = c.get(Calendar.DATE);
        c.set(Calendar.DATE, day + num);

        String dayAfter = new SimpleDateFormat(dateFormat).format(c.getTime());
        return dayAfter;
    }

    /**
     * 把时间段拆分为指定时间点
     * 
     * @param startTime
     *            开始时间
     * @param endTime
     *            结束时间
     * @param timeAccuracy
     *            拆分时间精度
     * @param bol
     *             是否取用第一个点
     * @return 时间点集合
     * @author 左香勇
     * @date 2013-6-26 10:12
     */
    public static List<String> splitTimetoPoint(String startTime,
            String endTime, int timeAccuracy,boolean bol) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        try {
            c1.setTime(sdf.parse(startTime));
            c2.setTime(sdf.parse(endTime));
        } catch (java.text.ParseException e) {
            System.err.println("格式不正确");
        }
        List<String> list = new ArrayList<String>();
        while (true) {
            list.add(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(c1
                    .getTime()));
            c1.set(Calendar.MINUTE, c1.get(Calendar.MINUTE) + timeAccuracy);
            if (c1.compareTo(c2) > 0) {
                break;
            }
        }
        if(!bol){
            list.remove(startTime);
        }
        return list;

    }

    /**
     * 日期转换成字符串
     * 
     * @param date
     * @return str
     */
    public static String dateToStr(Date date, String dateformat) {

        SimpleDateFormat format = new SimpleDateFormat(dateformat);
        String str = format.format(date);
        return str;
    }

    /**
     * 字符串转换成日期
     * 
     * @param str
     * @return date
     */
    public static Date strToYYYYMMDD(String str) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = format.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
    
    
    /**
     * 字符串转换成日期
     * 
     * @param str
     * @return date
     */
    public static Date strToYYYYMMDDSS(String str) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        try {
            date = format.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
    
    /**
     * 字符串转换成日期
     * 
     * @param str
     * @return date
     */
    public static Date strToDate(String str, String dateFormat) {

        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        Date date = null;
        try {
            date = format.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }

    /**
     * 
     * 获取指定时间n分前或后的方法
     * 
     * @param dateStr
     *            指定的时间
     * @param minute
     *            n分钟
     * @param dateFormat
     *            时间的格式如（yyyy-MM-dd HH:mm:ss）
     * @return 指定时间n分前或后的时间
     * @author 左香勇
     */
    public static String getStrToDateByMilsec(String dateStr, int minute,
            String dateFormat) {
        return new SimpleDateFormat(dateFormat).format(new Date(strToDate(
                dateStr, dateFormat).getTime()
                + (minute * 60000)));
    }

    public static String mergeDateTime(String time) {

        return DateUtil.currentDate() + " " + time;
    }
    
    
    public static String currentHourMi() {
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        return sdf.format(new Date());
    }
    /**
     * 获取当前为本周的第几天
     * 
     * @return (1,2,3,4,5,6,7)
     * java 中定义周日为每周的第一天，所有要把获得的周几减一
     * 同时当为周末(0)时，改为7
     * @author 左香勇
     */
    public static int getDateWeek() {
        int weekDay=Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1;
        if(weekDay==0){
            weekDay = 7;
        }
        return weekDay;
    }

    /**
     * 比较两个时间的大小
     * 
     * @param date1
     * @param date2
     * @return date1>date2 = 1 ; date1==date2 = 0 ; date1 < date2 = -1
     */
    public static int compareDateTime(Date date1, Date date2) {
        if (date1.getTime() > date2.getTime()) {
            return 1;
        } else if (date1.getTime() < date2.getTime()) {
            return -1;
        } else {
            return 0;
        }
    }
    
    /**
     * 比较两个时间的大小
     * 
     * @param date1
     * @param date2
     * @return date1>date2 = 1 ; date1==date2 = 0 ; date1 < date2 = -1
     */
    public static int compareStrDateTime(String date1, String date2) {
        
        if (strToDate(date1,"yyyy-MM-dd HH:mm").getTime() > strToDate(date2,"yyyy-MM-dd HH:mm:ss").getTime()) {
            return 1;
        } else if (strToDate(date1,"yyyy-MM-dd HH:mm").getTime() < strToDate(date2,"yyyy-MM-dd HH:mm:ss").getTime()) {
            return -1;
        } else {
            return 0;
        }
    }

    /**
     * 比较两个时间的大小
     * 
     * @param date1
     * @param date2
     * @return date1>date2 = 1 ; date1==date2 = 0 ; date1 < date2 = -1
     */
    public static int compareStrDate(String date1, String date2) {
        
        if (strToDate(date1,"yyyy-MM-dd").getTime() > strToDate(date2,"yyyy-MM-dd").getTime()) {
            return 1;
        } else if (strToDate(date1,"yyyy-MM-dd").getTime() < strToDate(date2,"yyyy-MM-dd").getTime()) {
            return -1;
        } else {
            return 0;
        }
    }

    /**
     * 比较两个时间的大小
     * 
     * @param date1
     * @param date2
     * @return date1>date2 = 1 ;  date1 < date2 = -1
     */
    public static boolean compareStrHours(String date1, String date2) {
        if (strToDate(date1,"HH:mm").getTime() > strToDate(date2,"HH:mm").getTime()) {
            return true;
        } else if (strToDate(date1,"HH:mm").getTime() < strToDate(date2,"HH:mm").getTime()) {
            return false;
        }
		return false;
    }
    
    /**
     * 获取日期小时
     * @return
     */
    public static String getHour() {
        return currentDateTime().substring(11, 13);
    }


    /**
     * 
    * @Title: getEveryDayOfWeek 
    * @Description: 获取指定日期所在周的每一天
    * @param  date
    * @param @return    设定文件 
    * @return List<String>    返回类型 
    * @author lin
    * @throws
     */
    public static List<String> getEveryDayOfWeek(Date date) {
        List<String> days = new ArrayList<String>();
        Calendar c1 = Calendar.getInstance();
        c1.setTime(date);
        int d = c1.get(Calendar.DAY_OF_WEEK);// SUNDAY：1，MONDAY：2，……SATURDAY：7
        if(d==1) {// 周日
            d = 7;
        } else {
            d --;
        }
        Long fTime = c1.getTimeInMillis() - d * 24 * 3600000;
        Date fdate;  
        for(int i = 0; i < 7; i ++) {
            fdate = new Date();
            fdate.setTime(fTime + ((i+1) * 24 * 3600000));  
            days.add(DateUtil.dateToStr(fdate, "yyyy-MM-dd"));
        }
        return days;
    }
    
    /**
     * 
    * @Title: getFirstLastDayOfMonth 
    * @Description: 获取指定日期所在月份的第一天和最后一天
    * @param @param date
    * @param @return    设定文件 
    * @return List<String>    返回类型 
    * @author lin
    * @throws
     */
    public static List<String> getFirstLastDayOfMonth(Date date) {
        List<String> days = new ArrayList<String>();
        
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        c1.setTime(date);
        c2.setTime(date);
        
        c1.set(Calendar.DAY_OF_MONTH, 1);// 设为月份的第1天
        
        c2.add(Calendar.MONTH, +1); // 将后一个值设置为下一个月
        c2.set(Calendar.DAY_OF_MONTH, 1);// 设为下一个月份的第1天
        c2.add(Calendar.DAY_OF_MONTH, -1);// 再减一天即为当月最后一天
        
        String firstday = DateUtil.dateToStr(new Date(c1.getTimeInMillis()), "yyyy-MM-dd");
        days.add(firstday);
        
        String lastday = DateUtil.dateToStr(new Date(c2.getTimeInMillis()), "yyyy-MM-dd");
        days.add(lastday);
        
        return days;
    }
    
    /**
     * 
    * @Title: getFirstDayOfQuarter 
    * @Description: 得到本季度第一天和最后一天的日期
    * @param @param date
    * @param @return    设定文件 
    * @return Date    返回类型 
    * @author lin
    * @throws
     */
    public static List<String> getFirstLastDayOfQuarter(Date date)   {     
        Calendar cDay = Calendar.getInstance();     
        Calendar eDay = Calendar.getInstance();     
        cDay.setTime(date);  
        eDay.setTime(date);  
        int curMonth = cDay.get(Calendar.MONTH);  
        if (curMonth >= Calendar.JANUARY && curMonth <= Calendar.MARCH){    
            cDay.set(Calendar.MONTH, Calendar.JANUARY);  
            eDay.set(Calendar.MONTH, Calendar.MARCH);  
        }  
        if (curMonth >= Calendar.APRIL && curMonth <= Calendar.JUNE){    
            cDay.set(Calendar.MONTH, Calendar.APRIL);  
            eDay.set(Calendar.MONTH, Calendar.JUNE);  
        }  
        if (curMonth >= Calendar.JULY && curMonth <= Calendar.SEPTEMBER) {    
            cDay.set(Calendar.MONTH, Calendar.JULY);  
            eDay.set(Calendar.MONTH, Calendar.SEPTEMBER);  
        }  
        if (curMonth >= Calendar.OCTOBER && curMonth <= Calendar.DECEMBER) {    
            cDay.set(Calendar.MONTH, Calendar.OCTOBER);  
            eDay.set(Calendar.MONTH, Calendar.DECEMBER);  
        }  
        cDay.set(Calendar.DAY_OF_MONTH, 1);  // 设置为第1天
        eDay.add(Calendar.MONTH, +1); // 将后一个值设置为下一个月
        eDay.set(Calendar.DAY_OF_MONTH, 1);// 设为下一个月份的第1天
        eDay.add(Calendar.DAY_OF_MONTH, -1);// 再减一天即为当月最后一天
        
        List<String> days = new ArrayList<String>();
        String firstday = DateUtil.dateToStr(new Date(cDay.getTimeInMillis()), "yyyy-MM-dd");
        days.add(firstday);
        String lastday = DateUtil.dateToStr(new Date(eDay.getTimeInMillis()), "yyyy-MM-dd");
        days.add(lastday);
        
        return days; 
    }  
    
    /**
     * 
     * @Title: getFirstLastDayOfYear 
     * @Description: TODO(得到本年第一天和最后一天的日期) 
     * @param @param date
     * @param @return    设定文件 
     * @return Date    返回类型 
     * @author lin
     * @throws
     */
    public static List<String> getFirstLastDayOfYear(Date date)   {     
        Calendar cDay = Calendar.getInstance();     
        Calendar eDay = Calendar.getInstance();     
        cDay.setTime(date);  
        eDay.setTime(date);  
        cDay.set(Calendar.MONTH, Calendar.JANUARY);  
        eDay.set(Calendar.MONTH, Calendar.DECEMBER);  
        cDay.set(Calendar.DAY_OF_MONTH, 1);  // 设置为第1天
        eDay.add(Calendar.MONTH, +1); // 将后一个值设置为下一个月
        eDay.set(Calendar.DAY_OF_MONTH, 1);// 设为下一个月份的第1天
        eDay.add(Calendar.DAY_OF_MONTH, -1);// 再减一天即为当月最后一天
        
        List<String> days = new ArrayList<String>();
        String firstday = DateUtil.dateToStr(new Date(cDay.getTimeInMillis()), "yyyy-MM-dd");
        days.add(firstday);
        String lastday = DateUtil.dateToStr(new Date(eDay.getTimeInMillis()), "yyyy-MM-dd");
        days.add(lastday);
        
        return days; 
    }  
    
    /**
     * 
    * @Title: getTwoDay （取绝对值）
    * @Description: TODO(计算两个日期之间间隔的天数，包含两个日期，入两个日期相同则为 1天) 
    * @param @param date1
    * @param @param date2
    * @param @return    设定文件 
    * @return List<String>    返回类型 
    * @throws
     */
    public static int getTwoDay(Date date1, Date date2) {     
        Calendar cDay = Calendar.getInstance();     
        Calendar eDay = Calendar.getInstance();     
        cDay.setTime(date1);  
        eDay.setTime(date2);  
        int days = 1;
        days = (int) Math.abs((date1.getTime() - date2.getTime()) / (24 * 60 * 60 * 1000)) + 1;
        return days; 
    }  
    
    /**
     * 计算两个日期间的天数（不取绝对值）
     * 
     * @param fromDate
     *            起始日期
     * @param toDate
     *            结束日期
     * @return
     * @throws ParseException
     */
    public static int dateDiff(String fromDate, String toDate)
            throws ParseException {
        int days = 0;
        SimpleDateFormat df =null;
        try{
         df = new SimpleDateFormat("yyyy-MM-dd");
        }catch (Exception e) {
            df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        }
        Date from = df.parse(fromDate);
        Date to = df.parse(toDate);
        long snum = to.getTime() - from.getTime();
        days = (int)(snum/(24 * 60 * 60 * 1000)
                + 1);

        return days;
    }
    
    /**
 	 * 求2个时间 相差多少分钟
 	 * 
 	 * @param endDate 结束时间
 	 * @param nowDate 开始时间
 	 * @return int
 	 */
	public static Integer getDateBetweenMinute(Date endDate, Date nowDate) {
	    long diff = endDate.getTime() - nowDate.getTime();
        Long  min = diff / (60 * 1000);
	    return min.intValue();
	}

    /**
     * 求2个时间 相差多少分钟
     *
     * @param end 结束时间
     * @param start 开始时间
     * @return int
     */
	public static int getStringBetweenMinute(String end,String start) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
           return  DateUtil.getDateBetweenMinute(df.parse(end),df.parse(start));
        }catch (ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }

    /**
     * 两个时间相隔几天几时几分
     * @param endDate
     * @param nowDate
     * @return
     */
	public static String getDatePoor(Date endDate, Date nowDate) {
		 
	    long nd = 1000 * 24 * 60 * 60;
	    long nh = 1000 * 60 * 60;
	    long nm = 1000 * 60;
	    // long ns = 1000;
	    // 获得两个时间的毫秒时间差异
	    long diff = endDate.getTime() - nowDate.getTime();
	    // 计算差多少天
	    long day = diff / nd;
	    // 计算差多少小时
	    long hour = diff % nd / nh;
	    // 计算差多少分钟
	    long min = diff % nd % nh / nm;
	    // 计算差多少秒//输出结果
	    // long sec = diff % nd % nh % nm / ns;
	    return day + "天" + hour + "小时" + min + "分钟";
	}
	
	
	  /**
		 * 求2个时间 相差多少小时
		 * 
		 * @param end 结束时间
		 * @param start 开始时间
		 * @return int
		 */
		public static Integer getBetween(Date end, Date start) {
			Long difference = end.getTime() - start.getTime();
			Integer hour = 1000 * 60 * 60;
			Integer date = (int) (difference / hour);
			return  date;
		}

    /**
     * 获取周的第一天和最后一天日期
     * @param time
     * @return
     */
	 public static Map<String, Object> convertWeekByDate(Date time) {
		Map<String, Object> map = new HashMap<>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 设置时间格式
		Calendar cal = Calendar.getInstance();
		cal.setTime(time);
		// 判断要计算的日期是否是周日，如果是则减一天计算周六的，否则会出问题，计算到下一周去了
		int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
		if (1 == dayWeek) {
			cal.add(Calendar.DAY_OF_MONTH, -1);
		}
		System.out.println("要计算日期为:" + sdf.format(cal.getTime())); // 输出要计算日期
		cal.setFirstDayOfWeek(Calendar.MONDAY);// 设置一个星期的第一天，按中国的习惯一个星期的第一天是星期一
		int day = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
		cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);// 根据日历的规则，给当前日期减去星期几与一个星期第一天的差值
		String imptimeBegin = sdf.format(cal.getTime());
		System.out.println("所在周星期一的日期：" + imptimeBegin);
		map.put("startTime", imptimeBegin + " 00:00:00");
		cal.add(Calendar.DATE, 6);
		String imptimeEnd = sdf.format(cal.getTime());
		System.out.println("所在周星期日的日期：" + imptimeEnd);
		map.put("endTime", imptimeEnd + " 23:59:59");
		return map;

	 }
    /**
     * 获取月的第一天和最后一天日期
     * @return
     */
     public static Map<String, Object> getMonthMap() {
        Map<String, Object> map = new HashMap<>();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        // 获取当前月第一天：
        Calendar c = Calendar.getInstance();
        c.add(Calendar.MONTH, 0);
        c.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天
        String firstDay = format.format(c.getTime());
        map.put("startTime", firstDay + " 00:00:00");
        // 获取当前月最后一天
        Calendar ca = Calendar.getInstance();
        ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
        String lastDay = format.format(ca.getTime());
        map.put("endTime", lastDay + " 23:59:59");
        return map;
     }

    /**
     * 功能描述: 添加时间 按年
     * @Author: 王培喜 58528792@163.com
     * @Date: 2020/9/17 14:55
     */
    public static Date addYear(Date date,int year){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);//设置起时间
        cal.add(Calendar.YEAR, year);//增加几年
        return cal.getTime();
    }

    /**
     * 功能描述: 添加时间 按月
     * @Author: 王培喜 58528792@163.com
     * @Date: 2020/9/17 14:55
     */
    public static Date addMonth(Date date,int month){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);//设置起时间
        cal.add(Calendar.MONTH, month);//增加月
        return cal.getTime();
    }
    /**
     * 功能描述: 添加时间 按天
     * @Author: 王培喜 58528792@163.com
     * @Date: 2020/9/17 14:55
     */
    public static Date addDay(Date date,int day){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);//设置起时间
        cal.add(Calendar.DATE, day);//增加一天
        return cal.getTime();
    }
    /**
     * 功能描述: 添加时间 按时
     * @Author: 王培喜 58528792@163.com
     * @Date: 2020/9/17 14:55
     */
    public static Date addHours(Date date,int hours){
        long time = date.getTime();
        long h = hours * 60 * 60 * 1000;
        return new Date(time + h);
    }
    /**
     * 功能描述: 添加时间 按分
     * @Author: 王培喜 58528792@163.com
     * @Date: 2020/9/17 14:55
     */
    public static Date addMinutes(Date date,int minutes){
        long time = date.getTime();
        long m = minutes  * 60 * 1000;
        return new Date(time + m);
    }
}
